class Solution:
    def canCompleteCircuit(self, gas: list[int], cost: list[int]) -> int:
        start_index = 0
        n  = len(gas)
        gas.extend(gas[:-1])
        cost.extend(cost[:-1])
        count  = 0
        for i in range(len(gas)):
            count += gas[i]-cost[i]
            if count < 0:
                count = 0
                start_index = i+1
        if start_index==2*n:
            return -1
        return start_index

S = Solution()
S.canCompleteCircuit(gas =[4,5,2,6,5,3], cost = [3,2,7,3,2,9])